const Router = require('koa-router');
const NewsController = require('../controllers/newsController');
const requireAuth = require('../middleware/auth');

const router = new Router();
const newsController = new NewsController();

// 新闻相关路由
router.get('/newsList', newsController.getNewsList.bind(newsController));
router.get('/detail/:id', newsController.getNewsById.bind(newsController));
router.post('/insertNews', requireAuth, requireAuth.requireScope(['write']), newsController.createNews.bind(newsController));
router.post('/updateNews', requireAuth, requireAuth.requireScope(['write']), newsController.updateNews.bind(newsController));
router.post('/selectAllCountClassReal', newsController.getNewsCountByClass.bind(newsController));
router.post('/deleteNews', requireAuth, requireAuth.requireScope(['write']), newsController.deleteNews.bind(newsController));
// 发布相关
router.post('/releaseList', newsController.getSelectedNewsList.bind(newsController));
router.post('/order', requireAuth, requireAuth.requireScope(['write']), newsController.sortReleaseList.bind(newsController));
// 新增：期刊新闻列表
router.get('/issueNews', newsController.getIssueNews.bind(newsController));
router.post('/newsIssueTemplate', newsController.getPublishTemplate.bind(newsController));
router.post('/publishReleaseList', requireAuth, requireAuth.requireScope(['write']), newsController.publishReleaseListAndClear.bind(newsController));
router.post('/updatePublish', requireAuth, requireAuth.requireScope(['write']), newsController.updatePublishSchedule.bind(newsController));
router.post('/issueList', newsController.getIssueList.bind(newsController));

module.exports = router;